#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "../../src/gtthread.h"

const int num_threads = 10;

void *thread(void *a)
{
  int i = 0;
  int v = *(int *)a;

  while (i < 5) {
    printf("I am thread %d\n", v);
    sleep(1);
    ++i;
  }
}

int main()
{
  int i;
  gtthread_t gt[num_threads];
  int id[num_threads];
  gtthread_init(1000);
  for (i=0; i<num_threads; ++i) id[i] = i;
  for (i=0; i<num_threads; ++i) {
    gtthread_create(&gt[i], thread, &id[i]);
    printf("thread %d created\n", i);
  }
  for (i=0; i<num_threads; ++i)
    gtthread_join(gt[i], NULL);

  return 0;
}
